<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 


<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Add User</title>		
		
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<meta http-equiv="Cache-Control" content="no-store"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>

<link rel="stylesheet" type="text/css"  href="css/jquery-ui-1.7.2.custom.css"/>
<link rel="stylesheet" type="text/css"  href="css/main.css"/>
<script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="scripts/jquery.bgiframe.min.js"></script>
<script type="text/javascript" src="scripts/jquery.livequery.js"></script>
<script type="text/javascript" src="scripts/jquery.loxia-1.1.min.js"></script>

<script type="text/javascript">
	var $j = jQuery.noConflict();
	
	$j(document).ready(function(){
		loxia.init({debug: true});		
	});	
</script>		
		<style>		
			#main {width: 98%; margin-left: auto; margin-right: auto;}
		</style>
		<script type="text/javascript">		
			$j(document).ready(function(){
			});	
			function checkUserUnique(value){
				var data = loxia.syncXhrGet('/basicwebapp/commons/checkuserunique.do',{data: {"user.loginName": value}});
				if(data.unique)
					return loxia.SUCCESS;
				if(data.exception)
					return "System Error";
				return "Input is used, please change another one.";
			}
			function addUser(){
				showErrorMsg("");
				loxia.lockPage();
				var form = $j("#addUserForm").get(0);
				var errorMsg = loxia.validateForm(form);
				if(errorMsg.length == 0){
					var data = loxia.syncXhrPost('/basicwebapp/user/adduser.do',{form: form});
					if(data.result){
						opener.$userlistTable.reload();
						window.close();
					}else{
						loxia.unlockPage();
						showErrorMsg(data.exception.message || "System Error.");
					}						
				}else{
					loxia.unlockPage();
			    	showErrorMsg(errorMsg);
				}				
			}
			function showErrorMsg(msg){
				var $info = $j("#info-block");
				if(msg){
					if(loxia.isString(msg)) msg = [msg];
					var lilist = "";
					for(var i=0; i< msg.length; i++)
						lilist += "<li>" + msg[i] + "</li>";
					$info.find("ul").html(lilist);
					$info.show();
				}else 
					$info.hide();
			}

			function checkLoginName(username)
			{
				var reg=/^[a-z A-Z][a-z A-Z \d \- _]*/; 
				return reg.test(str);   
			}

			function checkLength(value, obj){
				if(value.length > 20)
					return "please keep your length less-than 20";
				if(obj.name="user.password" && value.length <6 )
					return "password length must greater-than 6"
				return loxia.SUCCESS;
			}
		</script>
	</head>
	<body>
		<div id="main">
		
Administrator[admin] @ Headquater[Company]
			<div class="ui-state-active ui-corner-top" style="margin-bottom: 1px; padding: 2px 6px">Add New User</div>
			<div class="ui-widget ui-widget-content ui-corner-bottom" style="background-image: none; overflow: hidden; padding-left: 4px;padding-right: 4px;">
				<form id="addUserForm" name="addUserForm" action="/basicwebapp/user/adduserentry.do" method="post">
				<input type="hidden" name="struts.token.name" value="struts.token" />
<input type="hidden" name="struts.token" value="3TV5GQXG275LF4KUDVYXDMCDF0RQ5O17" />
				<table cellpadding="2" cellspacing="2" border="0" style="width: 100%;">
					<tr class="odd">
						<td class="label" style="text-align: right; padding-right: 4px;" width="100px">Login Name:</td>
						<td width="120px"><input loxiaType="input" name="user.loginName" required="true" trim="true"  style="width:95%" selectonfocus="true" checkmaster="checkUserUnique,checkLength" style="width:95%"/></td>
						<td class="hint">Choose one login name which should be unique in system.</td>
					</tr>
					<tr class="even">
						<td class="label" style="text-align: right; padding-right: 4px;">Password:</td>
						<td width="120px"><input loxiaType="input" name="user.password" required="true" trim="true" selectonfocus="true"  style="width:95%" checkmaster="checkLength"/></td>
						<td class="hint">Set the initial password</td>
					</tr>
					<tr class="odd">
						<td class="label" style="text-align: right; padding-right: 4px;">User Name:</td>
						<td width="120px"><input loxiaType="input" name="user.userName" required="true" trim="true" selectonfocus="true"  style="width:95%" checkmaster="checkLength"/></td>
						<td class="hint">Write the real user name.</td>
					</tr>
					<tr class="even">
						<td class="label" style="text-align: right; padding-right: 4px;">Description:</td>
						<td width="240px" ><textarea rows="5" name="input" loxiaType="input" name="user.description"  trim="true" selectonfocus="true" style="width:100%"></textarea></td>
						<td class="hint">Write down the user description.</td>
					</tr>
					<tr class="odd">
						<td class="label" style="text-align: right; padding-right: 4px;">System User?:</td>
						<td><input type="checkbox" name="user.isSystem" value="true" id="addUserForm_user_isSystem"/>
<input type="hidden" id="__checkbox_addUserForm_user_isSystem" name="__checkbox_user.isSystem" value="true" /> </td>
						<td class="hint">Is this user a system one or not</td>
					</tr>
					
				</table>
				</form>




				<div class="buttonbar">
					<input type="button" loxiaType="button" value="Add" onclick="addUser();"/>
				</div>
				<div class="ui-widget" id="info-block" style="display:none;">
				<div class="ui-state-highlight ui-corner-all"  style="padding: .3em .7em; width: auto;">
				<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: 0.3em; margin-top: 2px;"></span>
				<ul style="min-height:1%; list-style:none; margin: 0; padding-left: 0;">
				</ul>
				</p></div>
				</div>
			</div>
		</div>		
	</body>
</html>
